import { RequestData } from "@ant-design/pro-table";
import { SystemLogItem } from "./data";
import { request } from "umi";
import { SUCCESS_CODE } from "@/utils/request";
import { message } from "antd";

/**
 * 分页查询日志
 * @param params 
 * @returns 
 */
export async function pageQueryLog(params: {
    user_id?: string,
    operate?: string,
    page?: number,
    pageSize?: number,
}): Promise<RequestData<SystemLogItem>> {
    const res = await request('/log', {
        params: {
            page: 1,
            pageSize: 10,
            ...params,
        },
    });
    if (!res || res.code !== SUCCESS_CODE) {
        message.error('获取失败');
        return { success: false, total: 0, data: [] };
    }
    return {
        success: true,
        total: res.data.total,
        data: res.data.list,
    };
}